//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.example.demo.util;

public class ComplexCalculateUtils {

    public ComplexCalculateUtils() {
    }

    /**
     *
     * @param umb M侧故障相电压
     * @param imb M侧故障相电流
     * @param inb N侧故障相电流
     * @param im0 M侧零序电流3I0
     * @param k  零序补偿系数K
     * @param z1 线路单位长度正序阻抗z1
     * @param x 测距至M站
     * @return
     */
    public static Complex calculate(Complex umb,Complex imb,Complex inb,Complex im0,Complex k,Complex z1,Complex x) {
        Complex v1 = k.multiply(im0);
        System.out.println(v1.toString());
        Complex v2 = imb.add(v1);
        Complex v3 = v2.multiply(x).multiply(z1);
        Complex v4 = umb.substract(v3);
        Complex v5 = imb.add(inb);
        Complex rg = v4.divide(v5);
        return rg;
    }

    public static void main(String[] args) {
        Complex UMb = new Complex(32.3, 197.962234782294);
        Complex IMb = new Complex(22.20);
        Complex K = new Complex(0.50452541128653, -0.112834129040726);
        Complex IM0 = new Complex(22.34);
        Complex INb = new Complex(16.03,-12.3);
        Complex Z1 = new Complex(0.014616497829233, 0.254645441389291);
        Complex X = new Complex(26.73);
        Complex val = calculate(UMb, IMb, INb, IM0, K, Z1, X);
//        System.out.println(val.toString());
        //计算幅值
        double abs = val.abs();
        System.out.println(abs);
        //计算角度
        double arg = val.arg();
        System.out.println(arg);
    }

}
